package com.fluidops.keyword.util;

import java.util.concurrent.atomic.AtomicInteger;

import org.openrdf.model.URI;

public class SearchResult implements Comparable<SearchResult>{

	private static AtomicInteger resultID = new AtomicInteger();

	private URI uri;
	private double score;
	private int id;

	public SearchResult(URI uri, double score) {
		this.uri = uri;
		this.score = score;
		this.id = resultID.getAndIncrement();
	}

	@Override
	public int compareTo(SearchResult arg0) {
		if(this.score - arg0.score == 0d){
			return this.id - arg0.id;
		}else{
			return (int) (Math.signum(this.score - arg0.score));
		}

	}

	public boolean equals(Object o){
		if(o instanceof SearchResult){
			SearchResult s = (SearchResult) o;
			return this.uri.equals(s.uri) && this.score == s.score;
		}
		return false;
	}
	
	public URI getUri() {
		return uri;
	}

	public double getScore() {
		return score;
	}

	public void addScore(double addScore){
		this.score += addScore;
	}
	
}
